-- NOTE: uses extman.lua
-- Limitations: silently fails, does not copy metadata

local function backupDeFile(fname)
  local BLK = 1024 * 64
  bkname = os.getenv('TEMP')..'\\'..(fname:match'.*%\\(.-)$').."~"
  local inf = io.open(fname, "rb")
  local outf = io.open(bkname, "wb")
  if not inf or not outf then return end
  while true do
    local dat = inf:read(BLK)
    if not dat then break end
    outf:write(dat)
  end
  inf:close()
  outf:close()
end

scite_OnBeforeSave(backupDeFile)

